package com.yuufa.test.ex;

import org.apache.log4j.Logger;

public class Ex2 {
    
    public static Logger log = Logger.getLogger(Ex2.class);

    public static void main(String[] args) {
        prime(3000);
    }

    public static void prime(int n) {
        
        int[] s = new int[n+1];
        
        for (int i = 2; i <= n; i++) {
            s[i] = 1;
        }
        
        int k = 1;
        for (int i = 2; i <= n; i++) {
            if(s[i] == 1) {
                System.out.printf("%10d", i);
                if(k%10==0) {
                  System.out.println();
                }
                k++;
            }
            for(int j=i+i;j<=n;j+=i) {
                s[j] = 0;
            }
        }
        
//        int k = 1;
//        for (int i = 2; i <= n; i++) {
//            if(s[i] == 1) {
//                System.out.printf("%10d", i);
//                if(k%10==0) {
//                    System.out.println();
//                }
//                k++;
//            }
//        }
    }
}
